home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************************/
- /* */
- /* Module Name: SetSpeakerPhone */
- /* */
- /* File Name: SetSpeakerPhone.c */
- /* */
- /* © Apple Computer, Inc. 1994-1995 */
- /* All Rights Reserved */
- /* */
- /* Revision History: */
- /* */
- /* Date Who Modification */
- /* */
- /* 1994-07-27 Gary Anwyl Original version */
- /* */
- /************************************************************************************************/
-
- /****************************************** DESCRIPTION ******************************************
-
- This module display a dialog box in which the user can enable or
- disable the speakerphone. If the speakerphone is enabled the user
- can select the speaker volume. The microphone sensitivity cannot
- be adjusted.
-
- *************************************************************************************************/
-
- /******************************************** HEADERS *******************************************/
-
- #include "TextUtils.h"
-
- #include "TestModule.h"
-
- /****************************************** DEFINITIONS *****************************************/
-
- #define rGetThreeNumbersDLOG 10000
- #define kNumber1 3
- #define kNumber2 5
- #define kNumber3 7
-
- /****************************************** PROTOTYPES ******************************************/
-
- short GetThreeNumbers (short * , short *, short *);
- void DoTest (CHRSPtr paramPtr);
-
- /************************************************************************************************/
- /************************************************************************************************/
-
-
- pascal short TestModule (CHRSPtr paramPtr)
- {
- short returnValue = noErr;
-
- if (paramPtr->version <= kTestModuleVersion) {
-
- DoTest (paramPtr);
-
- }
- else
- returnValue = kWrongVersion;
-
- return (returnValue);
- }
-
-
- short GetThreeNumbers (short * number1, short * number2, short * number3)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
- short itemHit;
- DialogPtr theDialog;
- Str255 itemStr;
- long tlong;
-
- if ((theDialog = GetNewDialog (rGetThreeNumbersDLOG, nil, (WindowPtr)(-1L))) != nil) {
- GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
- SelIText (theDialog, kNumber1, 0, 32767);
-
- ShowWindow (theDialog);
-
- ModalDialog (nil, &itemHit);
-
- if (itemHit == ok) {
- GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, itemStr);
- StringToNum (itemStr, &tlong);
- *number1 = tlong;
-
- GetDItem (theDialog, kNumber2, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, itemStr);
- StringToNum (itemStr, &tlong);
- *number2 = tlong;
-
- GetDItem (theDialog, kNumber3, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, itemStr);
- StringToNum (itemStr, &tlong);
- *number3 = tlong;
- }
-
- DisposeDialog (theDialog);
- }
- else
- itemHit = -1;
-
- return (itemHit);
- }
-
-
- void DoTest (CHRSPtr paramPtr)
- {
- TELHandle termHand = GetCurrentTELHandle (paramPtr);
- short itemHit;
- OSErr errCode;
- short v1, v2, v3;
-
- if ((itemHit = GetThreeNumbers (&v1, &v2, &v3)) == ok) {
- if (v1 == 0) {
- Print (paramPtr, "SpeakerPhone off");
- v3 = 0;
- if ((errCode = TELSetVolume (termHand, telBuiltinSPVol, &v3, 1)) != noErr)
- Print (paramPtr, "### TELSetVolume failed : %d", errCode);
- if ((errCode = TELSetVolume (termHand, telBuiltinSPMicVol, &v3, 1)) != noErr)
- Print (paramPtr, "### TELSetVolume failed : %d", errCode);
- }
- else {
- Print (paramPtr, "SpeakerPhone on");
- if ((errCode = TELSetVolume (termHand, telBuiltinSPVol, &v2, 2)) != noErr)
- Print (paramPtr, "### TELSetVolume failed : %d", errCode);
- if ((errCode = TELSetVolume (termHand, telBuiltinSPMicVol, &v3, 2)) != noErr)
- Print (paramPtr, "### TELSetVolume failed : %d", errCode);
- }
- }
- else
- if (itemHit == -1)
- Print (paramPtr, "### Unable to get a DLOG resource");
- }
-
-
-